#include<bits/stdc++.h>
using namespace std;
int T;
int n,m,L,V;
struct dist
{
    int bg;
    int nd;//[bg,nd]
};
bool cmp(dist a,dist b)
{
    if(a.nd!=b.nd)
        return a.nd<b.nd;
    else
        return a.bg<b.bg;
}
dist car[100005];
int dct[100005];
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>T;
    while(T--)
    {
        cin>>n>>m>>L>>V;
        for(int i=1; i<=n; i++)
        {
            int d,v,a;
            cin>>d>>v>>a;
            if(v>V)
            {
                car[i].bg=d;
                if(a>=0)
                    car[i].nd=L;
                else
                    car[i].nd=min(L,(v*v-V*V)/(-2*a)+d+((v*v-V*V)%(-2*a)==0?-1:0));
            }
            else
            {
                if(a>0)
                    car[i].bg=min(L+1,(V*V-v*v)/(2*a)+d+((V*V-v*v)%(2*a)==0?2:1)),car[i].nd=L;
                else
                    car[i].bg=L+1;
            }
        }
        for(int i=1; i<=m; i++)
        {
            cin>>dct[i];
        }
        sort(dct+1,dct+1+m);
        for(int i=1; i<=n; i++)
        {
            if(car[i].bg==L+1||car[i].bg>car[i].nd)
                car[i].nd=car[i].bg=m+1;
            else
            {
                car[i].nd=int(upper_bound(dct+1,dct+m+1,car[i].nd)-dct)-1;
                car[i].bg=int(lower_bound(dct+1,dct+m+1,car[i].bg)-dct);
                if(car[i].nd<car[i].bg)
                    car[i].nd=car[i].bg=m+1;
            }
        }
        sort(car+1,car+1+n,cmp);
        int j=1;
        int las=0;
        int ans=0;
        for(int i=1;i<=m;i++)
        {
            bool ntc=0;//needed to change las
            while(j<=n&&car[j].nd==i)
            {
                if(car[j].bg>las)
                    ntc=1;
                j++;
            }
            if(ntc)
            {
                las=i;
                ++ans;
            }
        }
        cout<<j-1<<" "<<m-ans<<endl;
    }


    return 0;
}
